<template>
  <div>
    <h1>watch监视 情况一 ：监视【ref】定义的【基本类型】数据</h1>
    <h1>{{sum}}</h1>
    <button @click="changeSum">+</button>
  </div>
</template>
<script lang="ts" setup name="Person">
import { ref ,watch} from 'vue'
let sum=ref(0)
function changeSum(){
  sum.value +=1
}
const stopWatch = watch(sum, (newValue, oldValue) => {
  console.log(newValue, oldValue)
  if(newValue>5){
    //停止监视
    stopWatch()
  }
})
</script>
<style>

</style>